package com.jsnkj.basic.adapter

import android.app.Activity
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import android.widget.TextView
import androidx.recyclerview.widget.RecyclerView
import com.jsnkj.basic.R
import com.jsnkj.basic.bean.PopularizeBillsEntity


class DailyBillingAdapter(
    val activity: Activity,
    private val homeItemBeans: List<PopularizeBillsEntity.BillsBean>
) :
    RecyclerView.Adapter<DailyBillingAdapter.HomeViewHolder>() {
    override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): HomeViewHolder {
        val view: View =
            LayoutInflater.from(parent.context)
                .inflate(R.layout.rv_item_daily_billing, parent, false)
        return HomeViewHolder(view)
    }

    override fun onBindViewHolder(holder: HomeViewHolder, position: Int) {
        val item = homeItemBeans[position]

        holder.tvTime.text = item.date
        holder.tvIncentive.text = item.popularize_awards
        holder.tvInviteNew.text = item.invite_awards

        holder.tvTotalRevenue.text = item.commissions
        holder.tvSubsidy.text = item.activity_awards
    }

    override fun getItemCount(): Int {
        return homeItemBeans.size
    }

    class HomeViewHolder(itemView: View) : RecyclerView.ViewHolder(itemView) {
        var tvTime: TextView
        var tvIncentive: TextView
        var tvInviteNew: TextView
        var tvTotalRevenue: TextView
        var tvSubsidy: TextView

        init {
            tvTime = itemView.findViewById<TextView>(R.id.tv_time)
            tvIncentive = itemView.findViewById<TextView>(R.id.tv_incentive)
            tvInviteNew = itemView.findViewById<TextView>(R.id.tv_invite_new)
            tvTotalRevenue = itemView.findViewById<TextView>(R.id.tv_total_revenue)
            tvSubsidy = itemView.findViewById<TextView>(R.id.tv_subsidy)
        }
    }

}